# # import json
# # msg = b'{"status": "0"}'
# #
# # res = json.loads(msg)
# #
# # print(res)
#
#
# # rece_str = b'\xe2\x80\x9cstatus\xe2\x80\x9d'
# #
# # print(rece_str.decode())
#
# # import demjson
# # import json
# # rece_str = b'{\xe2\x80\x9cstatus\xe2\x80\x9d:\xe2\x80\x9d0\xe2\x80\x9d}'
# #
# #
# # print(json.loads())
#
#
# # import json
# # # 接收字节序列
# # byte_str = b'{\xe2\x80\x9cstatus\xe2\x80\x9d:\xe2\x80\x9d0\xe2\x80\x9d}'
# # # 将字节序列转换为字符串，并使用 json 模块解析
# # json_data = json.loads(byte_str.decode('utf-8'))
# # # 打印解析结果
# # print(json_data)
#
#
# # import json
# # # 接收字节序列
# # byte_str = b'{\xe2\x80\x9cstatus\xe2\x80\x9d:\xe2\x80\x9d0\xe2\x80\x9d}'
# # # 将字节序列转换为字符串，并使用 json 模块解析
# # json_data = json.loads(byte_str, ensure_ascii=False)
# # # 打印解析结果
# # print(json_data)
#
# import json
# import time
#
#
# # 接收字节序列
# # byte_str = b'{\xe2\x80\x9cstatus\xe2\x80\x9d:\xe2\x80\x9d0\xe2\x80\x9d}'
# # # 将字节序列转换为字符串
# # byte_str_str = byte_str.decode('utf-8')
# # print(byte_str_str)
# # # 使用 json.loads() 函数解析 JSON 数据
# #
# # # 替换斜着的双引号
# # json_data = byte_str_str.replace('“', '"')
# # print(json_data)
# # 解析 JSON 数据
# # data = json.loads(json_data)
# # print(data)
# # json_data = json.loads(byte_str_str)
# # # 打印解析结果
# # print(json_data)
# # import binascii
# # b_str = b'\xe2\x80\x9c'
# # print(b_str.decode('utf-8'))
# #
# # string = '\"'
# # hex_string = binascii.hexlify(string.encode())
# # print(hex_string)
# #
# #
# # print(ord('\"'))
# # res = "0x%04x" % ord('\"')
# # print('res', res)
#
# from multiprocessing import Process
#
# ts = True
#
# class A:
#     def __init__(self):
#         self.flag = True
#     def run(self):
#         i = 0
#         while True:
#             global ts
#             print('ts', ts)
#             if not ts:
#                 break
#             print('haha %s' %i)
#             time.sleep(1)
#             i += 1
#     def got(self):
#         time.sleep(10)
#         global ts
#         print('------------------------')
#         ts = False
#         print(ts)
#         print('!!!!!!!!!!!!!!! ')
#
#
# if __name__ == '__main__':
#     a = A()
#     p1 = Process(target=a.run)
#     p2 = Process(target=a.got)
#     p1.start()
#     p2.start()
#
#     p1.join()
#     p2.join()

#
import struct
import threading

# import bytearray

# 整数值
# value = 42
#
# # 定义字节格式
# format = ">I"
#
# # 将整数转换为字节
# bytes_value = struct.pack(format, value)
#
# # 将字节串转换为原始字节数组
# byte_array = bytearray(bytes_value)
#
# print(f"整数值：{value}")
# print(f"字节值：{bytes_value.hex()}")
# print(f"原始字节数组：{byte_array}")


# int variable
# num = 7
# # int to bytes
# num_bytes = num.to_bytes(2, byteorder='big')
# # display result and type
# print(num_bytes)
# print(type(num_bytes))


# print(bytes(str(1), 'utf-8'))

# print(bytearray([1, 2, 3]))
#
# br = bytearray([1, 2, 3])
# ar = list(br)
# print('ar', ar)

# i = 11
# res = bytes(str(i), 'utf-8')
# print(len(res))

# int variable
# num = 17
# # int to bytes
# num_bytes = num.to_bytes(1, byteorder='big')
# # display result and type
# print(num_bytes*2)
# print(type(num_bytes))
# print(len(num_bytes))

# res = b''
# for i in range(20):
#     num_byte = i.to_bytes(1, byteorder='big')
#     print(num_byte)
#     res += num_byte
#
# print(res)

# num = 9
# num_byte = num.to_bytes(1, byteorder='big')
# print(num_byte)
